import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Time:23:09
 */
public class demo8 {//

    public List<List<String>> groupAnagrams(String[] strs) {
        HashMap<String,List<String>> hash =new HashMap<>();
        for(String s : strs){
            char[] tmp = s.toCharArray();
            Arrays.sort(tmp);
            String key =new String(tmp);
            if(!hash.containsKey(key)){
                hash.put(key,new ArrayList<>());
            }
            hash.get(key).add(s);
        }
        return new ArrayList(hash.values());
    }
}
